//
//  UIButton+JGCustem.m
//  TwoTableLinkage
//
//  Created by ifly on 2017/7/14.
//  Copyright © 2017年 stkcctv. All rights reserved.
//

#import "UIButton+JGCustem.h"


@implementation UIButton (JGCustem)

+ (UIButton *) custemMainButton:(NSString *)title
                     wihtTarget:(id) target
                     withAction:(SEL) action
{
    UIButton *newbtn =[UIButton buttonWithType:UIButtonTypeCustom];
    [newbtn setTitle:title forState:UIControlStateNormal];
    [newbtn addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
    newbtn.layer.cornerRadius = 5;
    newbtn.layer.masksToBounds= YES;
    newbtn.titleLabel.font = [UIFont systemFontOfSize:16.0f];
    
    [newbtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [newbtn setBackgroundColor:[UIColor blueColor]];
    newbtn.layer.borderColor = [UIColor blueColor].CGColor;

    return newbtn;
}

+(UIButton *) custemButton:(NSString *)title
            withTitleColor:(UIColor *)titleColor
            withBlackColor:(UIColor *)blackColor
                wihtTarget:(id) target
                withAction:(SEL) action
            isCornerRadius:(BOOL) isRadius
{
    UIButton *newbtn =[UIButton buttonWithType:UIButtonTypeCustom];
    [newbtn setTitle:title forState:UIControlStateNormal];
    [newbtn addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
    [newbtn setTitleColor:titleColor forState:UIControlStateNormal];
    newbtn.backgroundColor = blackColor;
    [newbtn addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
    
    if (isRadius == YES) {
        newbtn.layer.cornerRadius = 5;
        newbtn.layer.masksToBounds= YES;
        newbtn.layer.borderColor = blackColor.CGColor;
    }
    
    return newbtn;
}


+(UIButton *)cutemButton:(NSString *)titele
          withTitleColor:(UIColor *)color
            withTextFont:(CGFloat) font
              wihtTarget:(id) target
              withAction:(SEL) action
{
    UIButton *newBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    
    [newBtn setTitleColor:color forState:UIControlStateNormal];
    [newBtn setTitle:titele forState:UIControlStateNormal];
    newBtn.titleLabel.font = [UIFont systemFontOfSize:font];
    [newBtn addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];

    return newBtn;
}


@end
